<div class="row">
    <div class="col-md-12 widget-module">
        <div class="box-widget">
            <div class="widget-head clearfix">
                <h4 class="pull-left"><?php echo $this->translate('create product'); ?></h4>
            </div>
            
            <div class="widget-container">
                <div class="widget-block">
                    <div class="widget-content">
                        <form id="usergroup" method="post" class="form-horizontal form-box">
                            <div class="form-group <?php echo $this->classError['name']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('product name'); ?></label>
                                <div class="col-lg-6">
                                    <input class="form-control" type="text" value="<?php echo $this->data['name']; ?>" name="name" class="form-control" placeholder="<?php echo $this->translate('product name'); ?>" />
                                    <?php echo $this->messageError['name']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['alias']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('alias'); ?></label>
                                <div class="col-lg-6">
                                    <input class="form-control" type="text" value="<?php echo $this->data['alias']; ?>" name="alias" class="form-control" placeholder="<?php echo $this->translate('alias'); ?>" />
                                    <?php echo $this->messageError['alias']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['category']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('category'); ?></label>
                                <div class="col-lg-6">
                                    <select name="category" class="form-control">
                                        <option value="0"><?php echo $this->translate('select'); ?></option>
                                        <?php foreach($this->categories as $category): ?>
                                            <option <?php if(isset($this->data['category']) && $this->data['category'] == $category->id) echo 'selected="selected"'; ?> value="<?php echo $category->id; ?>"><?php echo $category->category; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                    <?php echo $this->messageError['category']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['brand']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('brand'); ?></label>
                                <div class="col-lg-6">
                                    <select name="brand" class="form-control">
                                        <option value="0"><?php echo $this->translate('select'); ?></option>
                                        <?php foreach($this->brands as $brand): ?>
                                            <option <?php if(isset($this->data['brand']) && $this->data['brand'] == $brand->id) echo 'selected="selected"'; ?> value="<?php echo $brand->id; ?>"><?php echo $brand->brand; ?></option>
                                        <?php endforeach; ?>
                                    </select>
                                    <?php echo $this->messageError['brand']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['price']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('price'); ?></label>
                                <div class="col-lg-6">
                                    <input id="price" class="form-control" type="text" value="<?php echo $this->data['price']; ?>" name="price" class="form-control" placeholder="<?php echo $this->translate('price'); ?>" />
                                    <input type="hidden" name="price" value="<?php echo $this->data['price']; ?>" />
                                    <?php echo $this->messageError['price']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['image']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('image'); ?></label>
                                <div class="col-lg-6">
                                    <div class="input-group">
                                        <input id="image" class="form-control" type="text" value="<?php echo $this->data['image']; ?>" name="image" class="form-control" placeholder="<?php echo $this->translate('image'); ?>" />
                                        <span class="input-group-btn">
                                            <a id="iframe-btn" href="<?php echo $this->baseUrl(); ?>/filemanager/dialog.php?type=1&subfolder=&editor=mce_0&field_id=image">
                                                <button class="btn btn-default" type="button">
                                                    <span class="icon-folder-open" aria-hidden="true"></span>
                                                </button>
                                            </a>
                                        </span>
                                    </div>
                                    <?php echo $this->messageError['image']; ?>
                                </div>
                            </div>
                            
                            <?php
                                if(!isset($this->data['image'])){
                                    $src = $this->templateURL . "/images/grid-default-thumb.png";
                                }else{
                                    $src = $this->data['image'];
                                }
                            ?>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('current image'); ?></label>
                                <div class="col-lg-6">
                                    <div class="current-image">
                                        <img class="current-image" src="<?php echo $src; ?>" />
                                    </div>
                                </div>
                            </div>
                            
                            <div class="form-group <?php echo $this->classError['description']; ?>">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('description'); ?></label>
                                <div class="col-lg-6">
                                    <textarea rows="15" name="description" class="form-control"><?php echo $this->data['description']; ?></textarea>
                                    <?php echo $this->messageError['description']; ?>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label"><?php echo $this->translate('status'); ?></label>
                                <div class="col-lg-4">
                                    <div class="checkbox">
                                        <label>
                                            <input <?php if($this->data['status']) echo 'checked="checked"'; ?> type="checkbox" name="status" value="1" />
                                            <?php echo $this->translate('active'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-lg-2 control-label">&nbsp;</label>
                                <div class="col-lg-4">
                                    <div class="form-actions">
                                        <button id="save" type="submit" class="btn btn-primary">
                                            <i class="icon-save"></i>
                                            <?php echo $this->translate('save'); ?>
                                        </button>
                                        <button id="cancel" type="button" class="btn">
                                            <i class="icon-cancel-circle-2"></i>
                                            <?php echo $this->translate('cancel'); ?>
                                        </button>
                                    </div>
                                </div>
                            </div> 
                            <?php if(isset($this->data['id']) && $this->data['id'] > 0): ?>
                            <input type="hidden" name="id" value="<?php echo $this->data['id']; ?>" />
                            <input type="hidden" name="save" value="1" />
                            <?php endif; ?>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$("#cancel").click(function(){
    window.location = "<?php echo $this->url(array('module' => 'admin', 'controller' => 'product-category', 'action' => 'index'), null, true); ?>";
});

$("#save").click(function(){
    var price = $("#price").unmask();
    $("input[name='price']").val(price);
})

$(document).ready(function(){
    tinymce.init({
        document_base_url: "<?php echo $this->serverUrl("/shop/"); ?>",
        relative_urls: false,
        selector: "textarea",
        theme: "modern",
        theme_advanced_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
        font_size_style_values: "12px,13px,14px,16px,18px,20px",
        plugins: [
            "advlist autolink lists link image charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste responsivefilemanager textcolor"
        ],
        toolbar: "insertfile undo redo | styleselect | bold italic | fontselect | fontsizeselect | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | forecolor backcolor",
        external_filemanager_path:"<?php echo $this->baseUrl("/filemanager/"); ?>",
    	filemanager_title:"Responsive Filemanager" ,
    	external_plugins: { "filemanager" : "<?php echo $this->baseUrl("/filemanager/plugin.js"); ?>"}
    });
    
    $("input[id='price']").priceFormat({
        prefix: '',
        clearPrefix: true,
        thousandsSeparator: '.',
        centsLimit: 0
    });
    
    $('#iframe-btn').fancybox({	
    	'width'		: 900,
    	'height'	: 600,
    	'type'		: 'iframe',
        'autoScale'    	: false,
        'margin'    : 70,
    });
});
</script>